﻿//1.全局变量

//2.初始化界面展示方法
function fn_menuTree() {
    $('#GroupGeneral').tree({
    checkbox: true,
    url: "../Controller.aspx?controller=ReportRightsController&method=GetGroupRights&groupId=-1",
        
        onClick: function(node) {
            $(this).tree('toggle', node.target);
        },
        onLoadSuccess:function(node,data){
            //$('#GroupGeneral').tree('collapseAll');
        }
    });
}

function fn_groupGrid() {
    $('#groupgrid').datagrid({
        fit: true,
        fitColumns: true,
        rownumbers: true,
        singleSelect: true,
        url: '../Controller.aspx?controller=ReportRightsController&method=GetGroupList',
            onSelect: function() {
                var selected = $('#groupgrid').datagrid('getSelected');
	            if (selected) {
	                $('#GroupGeneral').tree('options').url="../Controller.aspx?controller=ReportRightsController&method=GetGroupRights&groupId="+selected.GroupId;
                    $('#GroupGeneral').tree('reload');
                }
            }
        });
    }
//3.初始化入口
    $(function() {
        fn_menuTree();
        fn_groupGrid();
    });

//4.页面方法
function generalgroup_save(){
    var selected = $('#groupgrid').datagrid('getSelected');
    if (selected) {
        var nodes = $('#GroupGeneral').tree('getChecked');
        var s = '';
			for(var i=0; i<nodes.length; i++){
			if(nodes[i].attributes.type==1){
				if (s != '') s += ',';
				s += nodes[i].id;
				}
			}
        var check={groupId:selected.GroupId,checkid:s};
        requestAjax('../Controller.aspx?controller=ReportRightsController&method=SaveGroupTitle',check);
    }
}
    
    
//********************************************************************************************

                       